﻿#include "productdlg.h"
#include "ui_productdlg.h"
#include <QFile>
#include <QMessageBox>
ProductDlg::ProductDlg(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ProductDlg)
{
    ui->setupUi(this);
    m_dProCreat = new ProCreateDlg(this);
    m_dProCreat->hide();
}

ProductDlg::~ProductDlg()
{
    delete ui;
}

void ProductDlg::on_createBt_clicked()
{
    m_dProCreat->show();
}

void ProductDlg::on_deleteBt_clicked()
{
	if (ui->listWidget->currentRow() < 0){
		return;
	}
    QString iniFilePath = ui->listWidget->currentItem()->text();
    if (QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("以下操作会删除配置文件：") + iniFilePath , tr("Yes"), tr("No")))
    {
        return;
    }
	iniFilePath = "Config/Product/" + iniFilePath + ".ini";
	DirFile(iniFilePath);
    emit sigProToMain(2);
}

void ProductDlg::on_confirmBt_clicked()
{
    m_nIndex = ui->listWidget->currentRow();
    emit sigProToMain(3);
    this->hide();
}


void ProductDlg::DirFile(QString iniFilePath)
{
    QFile fileTemp(iniFilePath);
    fileTemp.remove();
}
